package cc.vv.btpartyjob.jobactivities.activity

import android.support.v4.app.Fragment
import android.support.v4.view.ViewPager
import android.view.View
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.jnimodule.adapter.JniViewPageAdapter
import cc.vv.btpartyjob.jnimodule.binder.BaseBinder
import cc.vv.btpartyjob.jobactivities.R
import cc.vv.btpartyjob.jobactivities.delegate.HeXinJiaZhiActivityDelegate
import cc.vv.btpartyjob.jobactivities.fragment.HeXinJiaZhiFragment
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder

/**
 * 社会主义核心价值观
 * Created by Chen.qi on 2018/10/29.
 */
class HeXinJiaZhiActivity : BaseActivityMVP<HeXinJiaZhiActivityDelegate>() {

    /**
     * ViewPager适配器
     */
    private var mAdapter: JniViewPageAdapter? = null

    /**
     * Fragment集合
     */
    private var mFragments: ArrayList<Fragment>? = null

    private var arrState = listOf("0", "1", "2", "3", "4")

    private var pos: Int = 0

    override fun initData() {
        viewDelegate?.setTopBarTitle("社会主义核心价值观")
        mFragments = ArrayList()
        for (i in 0 until 5) {
            val fragment = HeXinJiaZhiFragment()
            fragment.setQueryState(arrState[i])
            mFragments!!.add(fragment)
        }
        mAdapter = JniViewPageAdapter(supportFragmentManager, mFragments!!)
        viewDelegate?.setAdapterData(mAdapter!!)
        viewDelegate?.setTextStatus(0)
    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }
        })

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //正常
            viewDelegate?.setViewPagerPos(0)

        }, R.id.tv_aszHj_projectNormal)


        viewDelegate?.setOnClickListener(View.OnClickListener {
            //预警
            viewDelegate?.setViewPagerPos(1)

        }, R.id.tv_aszHj_projectWarning)

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //延期
            viewDelegate?.setViewPagerPos(2)

        }, R.id.tv_aszHj_projectPostpone)


        viewDelegate?.setOnClickListener(View.OnClickListener {
            //取消
            viewDelegate?.setViewPagerPos(3)

        }, R.id.tv_aszHj_projectCancel)

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //结项
            viewDelegate?.setViewPagerPos(4)

        }, R.id.tv_aszHj_projectPDSP)


        viewDelegate?.bindViewPagerListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                viewDelegate?.setTextStatus(position)
                pos = position
            }
        })

        viewDelegate?.setOnClickListener(View.OnClickListener {
            //空事件
            viewDelegate?.showSearchView(false)
        }, R.id.rl_aszHj_searchTop)


        viewDelegate?.setOnClickListener(View.OnClickListener {
            //搜索
        }, R.id.tv_aszHj_searchBtn)

    }

    override fun getDelegateClass(): Class<HeXinJiaZhiActivityDelegate> {
        return HeXinJiaZhiActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

}